Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix tests on older IE #3800

Merged
merged 15 commits into from
Dec 2, 2016
Merged

test: fix tests on older IE #3800

merged 15 commits into from
Dec 2, 2016

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Nov 23, 2016

No description provided.

@gkatsev gkatsev changed the title test(player): use assert.throws for custom player test(): fix tests on older IE Nov 28, 2016
@gkatsev gkatsev changed the title test(): fix tests on older IE test: fix tests on older IE Nov 28, 2016
@@ -139,22 +139,22 @@ const TestHelpers = {
* @param {string} eventType
*/
triggerDomEvent(element, eventType) {
let event;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is for removing windows line-endings.

Copy link
Contributor

@brandonocasey brandonocasey Nov 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! (windows newline removals)

});

QUnit.test('should not allow to register custom player when any player has been created', function(assert) {
const tag = TestHelpers.makeTag();
const player = videojs(tag);

class CustomPlayer extends Player {}
try {

assert.throws(function() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.throws is better.

@@ -1269,19 +1280,23 @@ QUnit.test('should allow to register custom player when any player has not been

assert.equal(player instanceof CustomPlayer, true, 'player is custom');
player.dispose();

// reset the Player to the original value;
videojs.registerComponent('Player', Player);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the actual issue with custom player on IE8.

if (Player.players && Object.keys(Player.players).length > 0) {
if (Player.players &&
Object.keys(Player.players).length > 0 &&
Object.keys(Player.players).map((playerName) => Player.players[playerName]).every(Boolean)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether we want a comment here but basically, if all the items in Player.players are null, you're allowed to register a custom player. This is partly so we can reset the Player component properly for the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it deserves some kind of comment. Basically, what you just wrote! 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@misteroneill misteroneill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very minor suggestion. Otherwise, LGTM.

if (Player.players && Object.keys(Player.players).length > 0) {
if (Player.players &&
Object.keys(Player.players).length > 0 &&
Object.keys(Player.players).map((playerName) => Player.players[playerName]).every(Boolean)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it deserves some kind of comment. Basically, what you just wrote! 😆

@@ -139,22 +139,22 @@ const TestHelpers = {
* @param {string} eventType
*/
triggerDomEvent(element, eventType) {
let event;
Copy link
Contributor

@brandonocasey brandonocasey Nov 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! (windows newline removals)

@@ -435,7 +436,11 @@ test('chapters should be displayed when remote track added and load event fired'

equal(chaptersEl.track.cues.length, 2);

TestHelpers.triggerDomEvent(chaptersEl, 'load');
if (player.tech_.featuresNativeTextTracks) {
TestHelpers.triggerDomEvent(chaptersEl, 'load');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why/how are these two statements different?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On IE8 we use a custom DOM element for text tracks, however, IE8 doesn't allow us to trigger custom events on a custom element.
So, because everywhere we support native text tracks, we can trigger a real DOM event, we use that and where we use emulated tracks, we just trigger load directly on the chapters element object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a comment in the code for this, if you think it's necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should this check for IE8 instead? or maybe just add a comment to specify that this is a protection for IE8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided that a general solution would be better than specifically checking for IE8. However, I'll add a comment about this.

@gkatsev gkatsev added this to the 5.14 milestone Nov 29, 2016
@gkatsev gkatsev merged commit b4ebd9b into master Dec 2, 2016
@gkatsev gkatsev deleted the fix-custom-player-test branch December 2, 2016 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants